/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bank.gui;

import card.gui.*;
import frmwrk.core.FinancialFramework;
import frmwrk.interfaces.IAccount;
import frmwrk.interfaces.IEntry;
import gui.core.CoreFrame;
import gui.core.JDialog_AbstractArea;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.JLabel;
import javax.swing.JTextArea;

/**
 *
 * @author DCorrea
 */
public class JDialogGenBill extends JDialog_AbstractArea {

    javax.swing.JTextArea JTextArea;
    IAccount acc;

    public JDialogGenBill(IAccount acc) {
        this.acc = acc;
        JTextArea textFields = makeArea();
        getContentPane().add(textFields);
        JScrollPane1.setBounds(24, 24, 358, 240);
        JScrollPane1.getViewport().add(textFields);
        getContentPane().add(JScrollPane1);
    }

    @Override
    public JTextArea makeArea() {

        JTextArea = new javax.swing.JTextArea();
        JTextArea.setBounds(0, 0, 355, 237);
        String billstring;
        billstring = "Name= " + acc.getParty().getName() + "\r\n";
        billstring += "Address= " + acc.getParty().getStreet() + " " + acc.getParty().getState() + " " + acc.getParty().getZip() + "\r\n";
        billstring += "Account number= " + acc.getAccountNumber() + "\r\n";
        billstring += "Account type= " + acc.getAccountType() + "\r\n";
        billstring += "Balance = $ " + acc.getBalance() + "\r\n";
        billstring += "Balance History:\r\n";
        for (IEntry entry : acc.getEntryList()) {
            String date = entry.getDate().get(Calendar.YEAR) + "." + entry.getDate().get(Calendar.MONTH) + "."
                    + entry.getDate().get(Calendar.DATE) + " " + entry.getDate().get(Calendar.HOUR) + ":"
                    + entry.getDate().get(Calendar.MINUTE) + ":" + entry.getDate().get(Calendar.SECOND);
            billstring += date + " ||| " + "$ " + entry.getPreviousBalance() + "\r\n";
        }
        Calendar cal = new GregorianCalendar();
        String date = cal.get(Calendar.YEAR) + "." + cal.get(Calendar.MONTH) + "."
                + cal.get(Calendar.DATE) + " " + cal.get(Calendar.HOUR) + ":"
                + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND);

        billstring += date + " ||| " + "$ " + acc.getBalance() + "\r\n";
//        billstring += "Total Credits = $ 25.00\r\n";
//        billstring += "Total Charges = $ 560.00\r\n";
//        billstring += "New balance = $ 638.75\r\n";
//        billstring += "Total amount due = $ 63.88\r\n";
        JTextArea.setText(billstring);

        return JTextArea;
    }
}
